<div class="doc-item" id="doc-1257"><h2 class="doc-item-name">repl<span class="namespace">(clojure.contrib.repl-ln)</span></h2><ul class="var-arglists"><li>(<span class="var-name">repl</span> &amp; options)</li></ul><div class="var-docstring"><p>A repl that supports line numbers. For definitions and evaluations made
  at the repl, the repl-name and line number will be reported as the
  origin. Use set-repl-name and set-repl-prompt to customize the repl name
  and prompt. This repl supports all of the keyword arguments documented
  for clojure.main/repl with the following change and additions:</p><p>- :prompt has a new default
         default: #(clojure.core/print (repl-prompt))</p><p>- :name-fmt, Name format string
         default: the name-fmt of the parent repl, or &quot;repl-%S&quot;</p><p>- :prompt-fmt, Prompt format string
         default: the prompt-fmt of the parent repl, or &quot;%S:%L %N=&gt; &quot;</p></div><div class="var-source"><pre>; clojure/contrib/repl_ln.clj:217
(defn repl
  [&amp; options]
  (let [{:keys [init need-prompt prompt flush read eval print caught
                name-fmt prompt-fmt]
         :or {init        #()
              need-prompt (if (instance? LineNumberingPushbackReader *in*)
                            #(.atLineStart *in*)
                            #(identity true))
              prompt      #(clojure.core/print (repl-prompt))
              flush       flush
              read        clojure.main/repl-read
              eval        eval
              print       prn
              caught      clojure.main/repl-caught
              name-fmt    (*info* :name-fmt)
              prompt-fmt  (*info* :prompt-fmt)}}
              (apply hash-map options)]
    (try
     (Var/pushThreadBindings
      {Compiler/SOURCE (var-get Compiler/SOURCE)
       Compiler/LINE (var-get Compiler/LINE)
       (var *info*) *info*
       (var *private*) {}})
     (assoc! *info*
             :started (Date.)
             :serial (swap! *serial-number* inc)
             :thread (.getId (Thread/currentThread))
             :depth (inc (*info* :depth)))
     (assoc! *private*
             :prompt prompt)
     (set-repl-name name-fmt)
     (set-repl-prompt prompt-fmt)
     (clojure.main/repl
      :init init
      :need-prompt need-prompt
      :prompt prompt-hook
      :flush flush
      :read read
      :eval eval
      :print print
      :caught caught)
     (finally
      (Var/popThreadBindings)
      (prn)))))</pre></div><div class="license"><p>Copyright (c) Rich Hickey. All rights reserved.</p><p>The use and distribution terms for this software are covered by the <a href="http://opensource.org/licenses/eclipse-1.0.php">Eclipse Public License 1.0</a>, which can be found in the file
          epl-v10.html at the root of this distribution. By using this software
          in any fashion, you are agreeing to be bound by the terms of this
          license. You must not remove this notice, or any other, from this
          software.</p></div></div>